<?php

namespace App\Http\Controllers\Mapi;
use App\Http\Controllers\Controller;
use App\Http\Validators\BeatValidator;
use App\Http\Validators\LyricValidator;
use App\Services\BeatService;
use App\Services\CollectionService;
use App\Services\LyricService;
use App\Services\RhymeService;
use Illuminate\Http\Request;
use App\Api\Helper\ReturnMessage;
use Illuminate\Support\Facades\Cache;

class LyricController extends Controller
{

    /**
     * @param Request $request
     * @return \Dingo\Api\Http\Response
     * @name 词创作 删除
     * @user IHammer
     */
    public function LyricDelete(Request $request){
        $errmsg = "操作失败";
        $request->offsetSet("user_id",constant('_USER_ID'));
        $res = LyricService::LyricDeleteHandle($request,$errmsg);
        if($res){
            return ReturnMessage::success('操作成功');
        }
        return ReturnMessage::success($errmsg,1001);
    }
    /**
     * @param Request $request
     * @return \Dingo\Api\Http\Response
     * @name  词创作详情
     * @user IHammer
     */
    public function LyricInfo(Request $request){
        $request->offsetSet("user_id",constant('_USER_ID'));
        $lists = LyricService::LyricInfoHandle($request);
        return ReturnMessage::successArray($lists);
    }

    /**
     * @param Request $request
     * @return \Dingo\Api\Http\Response
     * @name 词创作列表
     * @user IHammer
     */
    public function LyricLists(Request $request){
        $request->offsetSet("user_id",constant('_USER_ID'));
        $lists = LyricService::LyricListsHandle($request);
        return ReturnMessage::successLists($lists);
    }

    /**
     * @param Request $request
     * @return \Dingo\Api\Http\Response
     * @name 歌词创作
     * @user IHammer
     */
    public function LyricCreate(Request $request){
        LyricValidator::create($request);
        $errmsg = "操作失败";
        $request->offsetSet("user_id",constant('_USER_ID'));
        $res = LyricService::LyricCreateHandle($request,$errmsg);
        if($res){
            return ReturnMessage::success('操作成功');
        }
        return ReturnMessage::success($errmsg,1001);
    }

    public function LyricEdit(Request $request){
        LyricValidator::create($request);
        $errmsg = "操作失败";
        $request->offsetSet("user_id",constant('_USER_ID'));
        $res = LyricService::LyricEditHandle($request,$errmsg);
        if($res){
            return ReturnMessage::success('操作成功');
        }
        return ReturnMessage::success($errmsg,1001);
    }
}
